/**
* \file DGVAnimatedScan.h
*
* \brief This file defines the class for doing animated 1D plots using only Qt and QWT.
* \author Shekhar S. Chandra, 2008
*
* This file is part of DGV Library.
*
* DGV is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* DGV is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with DGV.  If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DGVANIMATEDSCAN_H
#define DGVANIMATEDSCAN_H

#include <qwt_plot.h>

#include "DGVAliases.h"

/*!
    \class DGVAnimatedScan
    \brief This class handles the 1D animated plots of 2D data using Qwt.
    \author Shekhar S. Chandra, 2008

    This allows a 1D "scan" of 2D data where the interval of the frames can be adjusted.
*/
class DGV_EXPORT DGVAnimatedScan : public QwtPlot
{
    Q_OBJECT

public:
    DGVAnimatedScan(QWidget *parent = 0);
    DGVAnimatedScan(Array<imageType,2> &data, QString scanName, QWidget *parent = 0);
    virtual ~DGVAnimatedScan();

    /*!
        \fn DGVAnimatedScan::strippedName()
        \brief Returns the stripped (path removed) name of the scan.
    */
    QString strippedName();
    /*!
        \fn DGVAnimatedScan::strippedNamePrefix()
        \brief Returns the stripped (path removed) name of the scan with "Scan" prefix.
    */
    QString strippedNamePrefix();

public slots:
    void setTimerInterval(double interval);
    void saveFrame(QString filename);

protected:
    virtual void timerEvent(QTimerEvent *e);

private:
    int d_interval; // timer in ms
    int d_timerId;

    int plotRow;
    int frameNo;
    QString name;
    //bool saveAnimation;

    Array<imageType,1> xValues;
    Array<imageType,1> yValues;
    Array<imageType,2> *scanData; //!< Data to be scanned

    void alignScales();
    void setupCounter();
    void newValues();
};

#endif // DGVANIMATEDSCAN_H
